#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <pthread.h>
#include "foo.h"

extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size)
{
    pthread_t id;

    char *d = (char *)malloc(Size + 1);
    memcpy(d, Data, Size);
    d[Size] = 0;

    pthread_create(&id, NULL, foo, d);

    // Wait for foo() and retrieve value in ptr;
    pthread_join(id, NULL);

    free(d);
    return 0;
}